package com.witframework.web.tag.multicolumncombotag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class OptionTag extends BodyTagSupport
{
  private String sBody = null;
  private String value = null;
  private String title = null;
  private boolean selected = false;
  private String className = null;
  private String style = null;
  private String onMouseOver = null;
  private String onMouseOut = null;

  public void setStyle(String paramString)
  {
    this.style = paramString;
  }

  public String getStyle()
  {
    return this.style;
  }

  public void setClassName(String paramString)
  {
    this.className = paramString;
  }

  public String getClassName()
  {
    return this.className;
  }

  public void setValue(String paramString)
  {
    this.value = paramString;
  }

  public String getValue()
  {
    return this.value;
  }

  public void setTitle(String paramString)
  {
    this.title = paramString;
  }

  public String getTitle()
  {
    return this.title;
  }

  public void setSelected(boolean paramBoolean)
  {
    this.selected = paramBoolean;
  }

  public boolean getSelected()
  {
    return this.selected;
  }

  public void setOnMouseOver(String paramString)
  {
    this.onMouseOver = paramString;
  }

  public String getOnMouseOver()
  {
    return this.onMouseOver;
  }

  public void setOnMouseOut(String paramString)
  {
    this.onMouseOut = paramString;
  }

  public String getOnMouseOut()
  {
    return this.onMouseOut;
  }

  public int doAfterBody()
    throws JspException
  {
    BodyContent localBodyContent = getBodyContent();
    if (localBodyContent != null)
    {
      this.sBody = localBodyContent.getString();
      localBodyContent.clearBody();
    }
    return 0;
  }

  public int doEndTag()    throws JspException  {
    MultiColumnComboTag localMultiColumnComboTag = (MultiColumnComboTag)findAncestorWithClass(this, MultiColumnComboTag.class);
    if (localMultiColumnComboTag == null)
      throw new JspException("Could not find ancestor MultiColumnComboTag");
    if (this.sBody == null)
      this.sBody = "";
    else
      this.sBody = this.sBody.trim();
    OptionBean localOptionBean = new OptionBean();
    localOptionBean.setText(this.sBody);
    localOptionBean.setValue(this.value);
    localOptionBean.setTitle(this.title);
    localOptionBean.setSelected(this.selected);
    if (this.style != null)
      localOptionBean.setStyle(this.style);
    if (this.className != null)
      localOptionBean.setClassName(this.className);
    if (this.onMouseOver != null)
      localOptionBean.setOnMouseOver(this.onMouseOver);
    if (this.onMouseOut != null)
      localOptionBean.setOnMouseOut(this.onMouseOut);
    localMultiColumnComboTag.addElement(localOptionBean);
    dropData();
    return 6;
  }

  public void release()  {
    dropData();
    super.release();
  }

  private void dropData()  {
    this.sBody = null;
    this.style = null;
    this.className = null;
    this.value = null;
    this.selected = false;
    this.title = null;
    this.onMouseOver = null;
    this.onMouseOut = null;
  }
}
